<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html;charset=UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="font-size: 16px;">
<link rel="stylesheet" href="./common/js/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="./common/css/login.css?t=2021083108" />
<script src="./common/js/jquery/jquery.min.js?v=20210802"></script>
<script language="javascript" type="text/javascript" src="./common/js/jquery/jquery.form.js"></script>
<script src="./common/js/bootstrap/js/bootstrap.min.js"></script>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	<title>智能式用电安全监督于电能管理平台（政府版）</title>
</head>
<body>
	<!-- 页面头部 -->
	<div class="login-top">
		<img class="login-top-img" src="./common/imgs/login-top.png"/>
	</div>
	<!-- 页面中部 -->
	<div class="login-middle">
		<img class="login-middle-img" src="./common/imgs/login-middle.png"/>
		<div class="login-middle-a">
			<form action="UserAction.action" method="post" accept-charset="utf-8" id="user">
				<div class="input-group">
				  <span class="login-icon input-group-addon glyphicon glyphicon-phone"></span>
				  <input id="userName" name="name" type="text" class="form-control" placeholder="账号" aria-describedby="basic-addon1">
				</div>
				<div class="input-group login-input-pwd">
				  <span class="login-icon input-group-addon glyphicon glyphicon-lock"></span>
				  <input id="password" name="password" type="password" class="form-control" placeholder="密码" aria-describedby="basic-addon1">
				</div>
				<div class="input-group login-input-btn">
					<input id="btnS" type="submit" class="login-button btn btn-info" value="登录"/>
					<input type="reset" class="login-button btn btn-info btn-reset" value="重置">
				</div>
			</form>
		</div>
	</div>
	<!-- 页面尾部 -->
	<div class="login-bottom">
		<img class="login-bottom-img" src="./common/imgs/login-bottom.png"/>
	</div>
 
	<script>
		//表单提交
		var options = {
			type: 'post',
			beforeSubmit: showRequest,  //提交前的回调函数  
			success: showResponse,      //提交后的回调函数
			error: showResponseE,
		}

		function showRequest(formData, jqForm, options){
			alert("登录成功！");
			var username = $("#userName").val();
			var password = $("#password").val();
			if(username !== ""){
				if(password == ""){
					alert("密码为空！");
					return false;
				}
			}else{
				alert("账号为空！");
				return false;
			}
			return true;
		};

		function showResponse(responseText, statusText){
			if (responseText == "success") {
				alert("登录成功！");
				location.href='./index.html';
			}
		};

		function showResponseE(responseText, statusText){
			if (responseText == "success") {
				alert("密码错误！");
			}
		};
		$("#btnS").click(function(){
			if ($("#btnS").data("status") === 1) {
				return;
			}else{
				$("#btnS").data("status",1);
			}
			$("#info_form").ajaxSubmit(options);
			$("#btnS").data("status",0);
		})
		
	</script>
</body>
</html>
